﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;

namespace BootyBay.Models
{
    public enum AppStatus
    {
        NA = 0,
        NotSubmitted = 1,
        EmptyDescription = 2,
        NotPublished = 3,
        Published = 4,
        PublicStoreApp = 5
    }

    [DataContract]
    public class View_Application
    {
        [DataMember]
        public int Id { get; set; }
        [DataMember]
        public string ApplicationName { get; set; }
        [DataMember]
        public string MajorVersion { get; set; }
        [DataMember]
        public int Status { get; set; }
        [DataMember]
        public System.DateTime CreationDate { get; set; }
        [DataMember]
        public System.DateTime OperationDate { get; set; }
        [DataMember]
        public bool IsHidden { get; set; }
        [DataMember]
        public bool IsRecommended { get; set; }
        [DataMember]
        public bool IsPublicApp { get; set; }
        [DataMember]
        public int Id_ApplicationVersion { get; set; }
        [DataMember]
        public string StoreHttpUrl { get; set; }
        [DataMember]
        public string IdentityName { get; set; }
        [DataMember]
        public string Version { get; set; }
        [DataMember]
        public string Publisher { get; set; }
        [DataMember]
        public string ProcessorArchitecture { get; set; }
        [DataMember]
        public string DisplayName { get; set; }
        [DataMember]
        public string PublisherDisplayName { get; set; }
        [DataMember]
        public string Description { get; set; }
        [DataMember]
        public string Keywords { get; set; }
        [DataMember]
        public string ChangeLog { get; set; }       
        [DataMember]
        public int Category { get; set; }
        [DataMember]
        public string CategoryText { get; set; }
        [DataMember]
        public Nullable<int> Subcategory { get; set; }
        [DataMember]
        public string SubcategoryText { get; set; }
        [DataMember]
        public string LogoUrl_Store { get; set; }
        [DataMember]
        public string LogoUrl_150x150 { get; set; }
        [DataMember]
        public string LogoUrl_30x30 { get; set; }
        [DataMember]
        public string LogoUrl_310x150 { get; set; }
        [DataMember]
        public string LogoUrl_310x310 { get; set; }
        [DataMember]
        public string LogoUrl_70x70 { get; set; }
        [DataMember]
        public string ProtocolUrl { get; set; }
        [DataMember]
        public string ScreenshotUrls { get; set; }
        [DataMember]
        public System.DateTime VersionOperationDate { get; set; }
        [DataMember]
        public List<int> ProcessorArchitectureList
        {
            get
            {
                var list = new List<int>();
                int archi = 0;
                if (!string.IsNullOrEmpty(this.ProcessorArchitecture))
                {
                    var architectures = this.ProcessorArchitecture.Split(';');
                    foreach (var a in architectures)
                    {
                        if (int.TryParse(a, out archi))
                        {
                            list.Add(archi);
                        }
                    }
                }
                return list;
            }
        }
        [DataMember]
        public List<string> ScreenshotUrlList
        {
            get
            {
                var list = new List<string>();
                if (!string.IsNullOrEmpty(this.ScreenshotUrls))
                {
                    var urls = this.ScreenshotUrls.Split(';');
                    foreach (var url in urls)
                    {
                        if (!string.IsNullOrEmpty(url))
                        {
                            list.Add(url);
                        }
                    }
                }
                return list;
            }
        }
    }


}
